


#include <stdio.h>
#include <string.h>
#include <device.h>
#include <type.h>


#define read_sec sdc_read


void _memcpy(char *dst, char *src, int size)
{

    if (dst == NULL || src == NULL) 
        return;

    while (size--) *dst++ = *src++;

    //*dst = '0';

    return;
}

void _memset(char *dst, int val, int size)
{
    if (dst == NULL) return;

    while (size--) *dst++ = (0xff & val);

    //*dst = '0';
}



void dump_name(char *name, int size)
{
    char buf[128] = { 0 };
    int i = 0;

    //size/=2;

    while (size--)
    {

        //buf[i] = name[i];
        if (name[i] == 0xff)
        {
            LOG("FF,");
        } else if (name[i] == 0) LOG("00,");
        else LOG("%c,", name[i]);
        i++;
    }

    LOG(" \n");
}



#if 0
int fs_init()
{
    char buf[SEC_SIZE];
    int root_sec = 0;


    //read_sec(0xA000, (unsigned int *)buf, SEC_ONE);

    BIOS.BytesPerSector = buf[0xc]<<8 | buf[0xb];
    BIOS.SectorsPerCluster = buf[0xd];
    BIOS.ReservedSector = buf[0xf]<<8 | buf[0xe];
    BIOS.NumberOfFt = buf[0x10];
    BIOS.Sectors = buf[0x14]<<8 | buf[0x13];
    BIOS.SectorsPerFat = (buf[0x27]<<24) | (buf[0x26]<<16) | (buf[0x25]<<8) | buf[0x24];

    BIOS.root_sec = 0xA000 + BIOS.ReservedSector + BIOS.NumberOfFt * BIOS.SectorsPerFat;
    LOG("root_sec=%d\n", BIOS.root_sec);

    find_file(NULL);
}
#endif



int main()
{
    char buf[512];
    init_driver();

    sec_read(0, buf, 1);

    fs_init();
    find_at_dir();
    find_file("abc");

    close_driver();

    return 0;
}



int dump(char *buf)
{
     int idx, idx_, i = 0;

    for (idx_ = 0; idx_ < 16; idx_++)
    {
        for (idx = 0; idx < 32; idx++)
        {
            printf("%02x ", 0xff & buf[i++]);

        }
        printf("\n");
    }

}


